package com.svs.web.controller.api;

import com.microsoft.sqlserver.jdbc.StringUtils;
import com.svs.common.base.AjaxResult;
import com.svs.framework.util.ServletUtils;
import com.svs.framework.web.BackendController;
import com.svs.system.domain.SysDictData;
import com.svs.system.service.SysDictDataService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 数据字典信息
 */
@RestController
@RequestMapping("/api/dict/data")
public class ApiDictDataController extends BackendController {

    @Autowired
    private SysDictDataService dictDataService;

    @GetMapping("/list")
    public AjaxResult list(SysDictData dictData) {
        if (StringUtils.isEmpty(dictData.getDictType())) {
            String dictType = ServletUtils.getSession().getAttribute("dictType") + "";
            dictData.setDictType(dictType);
        }
        List<SysDictData> list = dictDataService.selectAllList(dictData);
        return AjaxResult.success("", list);
    }

}
